package proxyCommand;

//This is the Proxy that was used for the GUI.
public class HyPeerWebProxy {
	
    private GlobalObjectId globalObjectId;
    private static HyPeerWebProxy singleton;

    public HyPeerWebProxy(GlobalObjectId globalObjectId) {
        this.globalObjectId = globalObjectId;
    }
    
    public static HyPeerWebProxy getSingleton(GlobalObjectId id) {
        if(singleton == null || id != singleton.globalObjectId) {
        	singleton = new HyPeerWebProxy(id);
        }
        return singleton;
    }
    
    public GlobalObjectId getGlobalObjectId() {
    	return globalObjectId;
    }

    public boolean addToHyPeerWeb(int p0, int p1) {
        String[] parameterTypeNames = new String[2];
        parameterTypeNames[0] = "int";
        parameterTypeNames[1] = "int";
        Object[] actualParameters = new Object[2];
        actualParameters[0] = p0;
        actualParameters[1] = p1;
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "addToHyPeerWeb", parameterTypeNames, actualParameters, true);
        Object result = PeerCommunicator.getSingleton().sendSynchronous(globalObjectId, command);
        return (Boolean)result;
    }
    
    public boolean removeFromHyPeerWeb(int p0) {
        String[] parameterTypeNames = new String[1];
        parameterTypeNames[0] = "int";
        Object[] actualParameters = new Object[1];
        actualParameters[0] = p0;
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "removeFromHyPeerWeb", parameterTypeNames, actualParameters, true);
        Object result = PeerCommunicator.getSingleton().sendSynchronous(globalObjectId, command);
        return (Boolean)result;
    }
    
    public boolean send(int p0, int p1, String p2) {
    	String[] parameterTypeNames = new String[3];
        parameterTypeNames[0] = "int";
        parameterTypeNames[1] = "int";
        parameterTypeNames[2] = "java.lang.String";
        Object[] actualParameters = new Object[3];
        actualParameters[0] = p0;
        actualParameters[1] = p1;
        actualParameters[2] = p2;
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "send", parameterTypeNames, actualParameters, true);
        Object result = PeerCommunicator.getSingleton().sendSynchronous(globalObjectId, command);
        return (Boolean)result;
    }
    
    public boolean broadcast(int p0, String p1) {
    	String[] parameterTypeNames = new String[2];
        parameterTypeNames[0] = "int";
        parameterTypeNames[1] = "java.lang.String";
        Object[] actualParameters = new Object[2];
        actualParameters[0] = p0;
        actualParameters[1] = p1;
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "broadcast", parameterTypeNames, actualParameters, true);
        Object result = PeerCommunicator.getSingleton().sendSynchronous(globalObjectId, command);
        return (Boolean)result;
    }
    
    public int size() {
    	String[] parameterTypeNames = new String[0];
    	Object[] actualParameters = new Object[0];
    	Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "size", parameterTypeNames, actualParameters, true);
    	Object result = PeerCommunicator.getSingleton().sendSynchronous(globalObjectId, command);
    	return (Integer)result;
    }
    
    public String toString() {
        String[] parameterTypeNames = new String[0];
        Object[] actualParameters = new Object[0];
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "toString", parameterTypeNames, actualParameters, true);
        Object result = PeerCommunicator.getSingleton().sendSynchronous(globalObjectId, command);
        return (String)result;
    }
    
    public void clear() {
        String[] parameterTypeNames = new String[0];
        Object[] actualParameters = new Object[0];
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "clear", parameterTypeNames, actualParameters, false);
        PeerCommunicator.getSingleton().sendASynchronous(globalObjectId, command);
    }

    public void close() {
        String[] parameterTypeNames = new String[0];
        Object[] actualParameters = new Object[0];
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "close", parameterTypeNames, actualParameters, false);
        PeerCommunicator.getSingleton().sendASynchronous(globalObjectId, command);
    }
    
    public void connectToGUI(proxyCommand.GlobalObjectId p0) {
        String[] parameterTypeNames = new String[1];
        parameterTypeNames[0] = "proxyCommand.GlobalObjectId";
        Object[] actualParameters = new Object[1];
        actualParameters[0] = p0;
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "connectToGUI", parameterTypeNames, actualParameters, false);
        PeerCommunicator.getSingleton().sendASynchronous(globalObjectId, command);
    }
    
    public void addSegment(proxyCommand.GlobalObjectId p0, proxyCommand.GlobalObjectId p1) {
    	String[] parameterTypeNames = new String[2];
    	parameterTypeNames[0] = "proxyCommand.GlobalObjectId";
    	parameterTypeNames[1] = "proxyCommand.GlobalObjectId";
    	Object[] actualParameters = new Object[2];
    	actualParameters[0] = p0;
    	actualParameters[1] = p1;
    	Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "addSegment", parameterTypeNames, actualParameters, false);
    	PeerCommunicator.getSingleton().sendASynchronous(globalObjectId, command);
    }
    
    public boolean getGlobalSize(proxyCommand.GlobalObjectId p0, int p1) {
    	String[] parameterTypeNames = new String[2];
    	parameterTypeNames[0] = "proxyCommand.GlobalObjectId";
    	parameterTypeNames[1] = "int";
    	Object[] actualParameters = new Object[2];
    	actualParameters[0] = p0;
    	actualParameters[1] = p1;
    	Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "getGlobalSize", parameterTypeNames, actualParameters, true);
    	return (Boolean) PeerCommunicator.getSingleton().sendSynchronous(globalObjectId, command);
    }
    
    public boolean insertNode(hypeerweb.Node p0){
        String[] parameterTypeNames = new String[1];
        parameterTypeNames[0] = "hypeerweb.Node";
        Object[] actualParameters = new Object[1];
        actualParameters[0] = p0;
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "insertNode", parameterTypeNames, actualParameters, true);
        return (Boolean)PeerCommunicator.getSingleton().sendSynchronous(globalObjectId, command);
    }
    
    public void printHyPeerWeb(GlobalObjectId p0){
    	String[] parameterTypeNames = new String[1];
    	parameterTypeNames[0] = "proxyCommand.GlobalObjectId";
    	Object[] actualParameters = new Object[1];
    	actualParameters[0] = p0;
    	Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "printHyPeerWeb", parameterTypeNames, actualParameters, false);
        PeerCommunicator.getSingleton().sendASynchronous(globalObjectId, command);
    }
    
    public boolean acceptNodes(java.util.HashSet p0, proxyCommand.GlobalObjectId p1){
        String[] parameterTypeNames = new String[2];
        parameterTypeNames[0] = "java.util.HashSet";
        parameterTypeNames[1] = "proxyCommand.GlobalObjectId";
        Object[] actualParameters = new Object[2];
        actualParameters[0] = p0;
        actualParameters[1] = p1;
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "acceptNodes", parameterTypeNames, actualParameters, true);
        return (Boolean)PeerCommunicator.getSingleton().sendSynchronous(globalObjectId, command);
    }
    
    public void removeSegment(proxyCommand.GlobalObjectId p0, proxyCommand.GlobalObjectId p1){
        String[] parameterTypeNames = new String[2];
        parameterTypeNames[0] = "proxyCommand.GlobalObjectId";
        parameterTypeNames[1] = "proxyCommand.GlobalObjectId";
        Object[] actualParameters = new Object[2];
        actualParameters[0] = p0;
        actualParameters[1] = p1;
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "removeSegment", parameterTypeNames, actualParameters, false);
        PeerCommunicator.getSingleton().sendASynchronous(globalObjectId, command);
    }

	public void saveSegment(GlobalObjectId p0) {
		String[] parameterTypeNames = new String[1];
        parameterTypeNames[0] = "proxyCommand.GlobalObjectId";
        Object[] actualParameters = new Object[1];
        actualParameters[0] = p0;
        Command command = new Command(globalObjectId.getLocalObjectId(), "hypeerweb.HyPeerWeb", "saveSegment", parameterTypeNames, actualParameters, false);
        PeerCommunicator.getSingleton().sendASynchronous(globalObjectId, command);
	}
}
